<?php
	require_once APPPATH . 'controllers/base_controllers/base_controller.php';

	class Banquet_registration extends Base_controller
	{
		public static $REGISTRATION_TEMPLATE = 'templates/registration/registration_template';		
		
		
		public function __construct()
		{
			parent::__construct();
			
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
		}
		
		public function home( )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			
			$eventID = 1;
			
			$curyear = $this->Walk_proxy->getCurrentYear();
			
			$totnumreg = $this->Annualbanquet_proxy->getTotalNumReg( $eventID, $curyear );
			if ($totnumreg > 1000)
			{
					//Maximum registration capacity reached
					$data['title'] = $curyear.' '.$this->Annualbanquet_proxy->getEventName( $eventID ).' Sold Out';
					$data['eventid'] = $eventID;
					$data['curyear'] = $curyear;		
					$data['view'] = 'annualbanquet/home_page_bq_full_view';			
			}
			else
			{
				if ($this->Annualbanquet_proxy->isEventValid( $eventID ))
				{
					switch ($eventID)
					{
						case 1:
							$data['title'] = $curyear.' '.$this->Annualbanquet_proxy->getEventName( $eventID );
							$data['eventid'] = $eventID;
							$data['curyear'] = $curyear;		
							$data['view'] = 'annualbanquet/home_page_bq_view';
							//$data['view'] = 'annualbanquet/home_page_bq_full_view';
							break;
						default:
							echo "Bad Event ID";
							die;
					}
				}
				else
				{
					//Event date has passed
					$data['title'] = $curyear.' '.$this->Annualbanquet_proxy->getEventName( $eventID ).' Has Completed';
					$data['eventid'] = $eventID;
					$data['curyear'] = $curyear;		
					$data['view'] = 'annualbanquet/home_page_bq_closed_view';								
				}
			}
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function step1( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
			
			$curyear = $this->Walk_proxy->getCurrentYear();

			switch ($eventID)
			{
				case 1:
					$data['title'] = 'Registration for '.$curyear.' '.$this->Annualbanquet_proxy->getEventName( $eventID );
					$data['eventid'] = $eventID;
					$data['curyear'] = $curyear;
					$data['view'] = 'annualbanquet/registration_bq_input_view';
					break;
				default:
					echo "Bad Event ID";
					die;
			}
		
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		public function step1_process( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Paypal_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
			
			$curyear = $this->Walk_proxy->getCurrentYear();

			switch ($eventID)
			{
				case 1:
					if (is_numeric($this->input->post('numadultreg')))
						$numadults = intval($this->input->post('numadultreg'));
					else
						$numadults = 0;
					
					if (is_numeric($this->input->post('numchildreg')))
						$numchildren = intval($this->input->post('numchildreg'));
					else
						$numchildren = 0;

					if (is_numeric($this->input->post('donationamount')))
						$donation = floatval($this->input->post('donationamount'));
					else
						$donation = 0;

					//Check if already registered
					if ($this->Annualbanquet_proxy->isEventRegistered( $eventID, $this->input->post('firstname'), $this->input->post('lastname'), $this->input->post('email'), $curyear))
					{
						redirect( base_url() . 'annualbanquet/banquet_registration/event_registered/'.$eventID);
					}
					
					$bq_registration_value = new Annualbanquet_registration_value();
					
					$bq_registration_value->setEventID($eventID);
					$bq_registration_value->setCurrentYear($curyear);
					$bq_registration_value->setFirstName($this->input->post('firstname'));
					$bq_registration_value->setLastName($this->input->post('lastname'));
					$bq_registration_value->setEmail($this->input->post('email'));
					$bq_registration_value->setPhone($this->input->post('phoneNumber'));
					$bq_registration_value->setAddress($this->input->post('address'));
					$bq_registration_value->setCity($this->input->post('city'));
					$bq_registration_value->setState($this->input->post('state'));
					$bq_registration_value->setZip($this->input->post('zipCode'));
					$bq_registration_value->setNumAdultRegistered($numadults);
					$bq_registration_value->setNumChildRegistered($numchildren);
					$bq_registration_value->setRegistrationFeeAdult( $this->Annualbanquet_proxy->getAdultRegistrationFee( $eventID ) );
					$bq_registration_value->setRegistrationFeeChild( $this->Annualbanquet_proxy->getChildRegistrationFee( $eventID ) );
					$bq_registration_value->setDonation( $donation );
                    $bq_registration_value->setIsTeacher($this->input->post('isteacher'));

					break;
				default:
					echo "Bad Event ID";
					die;
			}

			//echo $bq_registration_value->getTotalRegistrationFee().'</br>';
			//die;

			//Create session variable
			$this->session->unset_userdata('bq_registration_value');
			$this->session->set_userdata('bq_registration_value', serialize($bq_registration_value));
			
			if ($this->session->userdata('sessionobj_temp_id') != "")
			{
				//There is already a session variable
				$paypalTempId = $this->session->userdata('sessionobj_temp_id');
				if ($paypalTempId <= 0)
				{
					redirect( base_url() . 'annualbanquet/banquet_registration/registration_error/'.$eventID);
				}				
				$this->Paypal_proxy->updateTempData( $paypalTempId, serialize($bq_registration_value) );
			}
			else
			{
				//No session variable
				$paypalTempId = $this->Paypal_proxy->addTempData( serialize($bq_registration_value) );
				if ($paypalTempId <= 0)
				{
					redirect( base_url() . 'annualbanquet/banquet_registration/registration_error/'.$eventID);
				}
				$this->session->set_userdata('sessionobj_temp_id', $paypalTempId);				
			}
			
			$numtotreg = $bq_registration_value->getNumAdultRegistered() + $bq_registration_value->getNumChildRegistered();
			$desc = $curyear.' '.$this->Annualbanquet_proxy->getEventName( $eventID );

			$data['title'] = $desc.' Registration Summary';
			$data['view'] = 'annualbanquet/bq_registration_summary_view';
			$data['bq_registration_value'] = $bq_registration_value;
			$data['paypal_form'] = $this->getPayPalForm( $bq_registration_value->getTotalRegistrationFee(), $numtotreg, $paypalTempId, $desc, $eventID );
			$data['eventid'] = $eventID;
			
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		//Admin edit banquet registrations
		public function admin_edit_bq_registrations( $adminUrlKey )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' );
			}
			
			//Get id for person who logged in
			$loginPersonId = $this->session->userdata( 'person_id' );
			if ( $loginPersonId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$this->session->unset_userdata( 'member_logged_in_key' );
			
			$this->session->set_userdata( 'admin_url_key', $adminUrlKey );
			$this->session->set_userdata( 'admin_sec_key', $seckey );

			$curyear = $this->Walk_proxy->getCurrentYear();
			
			$regInfo = $this->Annualbanquet_proxy->getAllBanquetRegistrations( $curyear );
			
/*			
			echo count($regInfo)."</br>";
			echo $bqrh_value->getFirstName()." ".$bqrh_value->getLastName()."</br>";
			die;
*/
			$data['title'] = 'Admin Edit Banquet Registrations ';
			$data['curyear'] = $curyear;
			$data['view'] = 'annualbanquet/admin_edit_bq_registrations_view';
			$data['regInfo'] = $regInfo;
			$data['urlKey'] = $adminUrlKey;
			$data['loggedinname'] = $this->Person_proxy->getPersonName( $loginPersonId );
			
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		//Get registration to edit
		public function admin_edit_bq_registrations_process( $bq_reg_history_id )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' );
			}
		
			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			//Get id for person who logged in
			$loginPersonId = $this->session->userdata( 'person_id' );
			if ( $loginPersonId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			if ((!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "banquet", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "superadmin" )))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );				
			}

			$curyear = $this->Walk_proxy->getCurrentYear();
			
			//Get registration value object
			$bq_registration_value = $this->Annualbanquet_proxy->getEventInfoYear($bq_reg_history_id, $curyear);
												
			$data['title'] = ' Admin Edit Banquet Registration';
			$data['curyear'] = $this->Walk_proxy->getCurrentYear();
			$data['view'] = 'annualbanquet/admin_edit_banquet_registration_view';
			$data['accountinfo'] = $bq_registration_value;
			$data['bq_reg_history_id'] = $bq_reg_history_id;
			$data['adminUrlKey'] = $this->session->userdata( 'admin_url_key' );
			$data['loggedinname'] = $this->Person_proxy->getPersonName( $loginPersonId );
						
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}

		//Admin edit registration process
		public function admin_edit_banquet_registration_process( $bq_reg_history_id )
		{
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
			$this->load->library('encrypt');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				echo "Admin is not logged in";
				die;
				redirect( base_url() . 'cmb/member/login_home/' );
			}
			
			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			//Get id for person who logged in
			$loginPersonId = $this->session->userdata( 'person_id' );
			if ( $loginPersonId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			if ((!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "banquet", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "admin" )) and (!$this->Person_proxy->isPersonGroupRole( $loginPersonId, "member", "superadmin" )))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );				
			}

			$curyear = $this->Walk_proxy->getCurrentYear();

			//Get registration value object
			$bq_registration_value = $this->Annualbanquet_proxy->getEventInfoYear($bq_reg_history_id, $curyear);
			
			//Update registration object
			if (is_numeric($this->input->post('numadultreg')))
				$numadults = intval($this->input->post('numadultreg'));
			else
				$numadults = 0;
			
			if (is_numeric($this->input->post('numchildreg')))
				$numchildren = intval($this->input->post('numchildreg'));
			else
				$numchildren = 0;

			if (is_numeric($this->input->post('donationamount')))
				$donation = intval($this->input->post('donationamount'));
			else
				$donation = 0;

			$bq_registration_value->setFirstName($this->input->post('firstname'));
			$bq_registration_value->setLastName($this->input->post('lastname'));
			$bq_registration_value->setEmail($this->input->post('email'));
			$bq_registration_value->setPhone($this->input->post('phone'));
			$bq_registration_value->setAddress($this->input->post('address'));
			$bq_registration_value->setCity($this->input->post('city'));
			$bq_registration_value->setState($this->input->post('state'));
			$bq_registration_value->setZip($this->input->post('zip'));
			$bq_registration_value->setNumAdultRegistered($numadults);
			$bq_registration_value->setNumChildRegistered($numchildren);
			$bq_registration_value->setDonation($donation);
			$bq_registration_value->setPaymentType($this->input->post('paymenttype'));
			$bq_registration_value->setCheckNum($this->input->post('checknum'));
			$bq_registration_value->setPaymentTransactionID($this->input->post('paytxn'));
			$bq_registration_value->setPaymentStatus($this->input->post('paymentstatus'));
			$bq_registration_value->setComments($this->input->post('comments'));
			
			//Update registration
			$this->Annualbanquet_proxy->updateBanquetRegistration( $bq_registration_value, intval($this->input->post('regstatus')) );
/*											
			$adminUrlKey = $this->session->userdata( 'admin_url_key' );
			$adminSeckey = $this->session->userdata( 'admin_sec_key' );
			$this->session->set_userdata( 'logged_in_key', $adminSeckey);
			$this->session->set_userdata( 'admin_is_logged_in', true);
*/			
			echo "Completed: ".$bq_registration_value->getFirstName()." ".$bq_registration_value->getLastName()."</br>";
			echo "Please close page</br>";
			die;
			//redirect( base_url() . 'cmb/member_registration/admin_edit_members/' . $adminUrlKey . '/' );
		}

		private function getPayPalForm( $amount, $qty, $paypalTempId, $desc, $eventID )
		{
			$this->load->library('Paypal_Lib');
			
		    $this->paypal_lib->add_field('return', site_url('/annualbanquet/banquet_registration/paypal_success/'.$eventID));
		    $this->paypal_lib->add_field('cancel_return', site_url('/annualbanquet/banquet_registration/paypal_cancel/'));
		    $this->paypal_lib->add_field('notify_url', site_url('/annualbanquet/banquet_registration/ipn/')); // <-- IPN url
		    $this->paypal_lib->add_field('custom', $paypalTempId); // <-- Verify return
	
		    $this->paypal_lib->add_field('item_name', $desc.' - '.$qty.' persons');
		    $this->paypal_lib->add_field('amount', $amount);
	
		    return $this->paypal_lib->paypal_form();			
		}

		public function ipn()
		{
			$this->load->model('proxies/Paypal_proxy');
			$this->load->library('Paypal_Lib');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');

			//$this->Walk_proxy->log_cmb_registration("Entered IPN code");
					
			if( $this->paypal_lib->validate_ipn() ) 
			{
				$this->Walk_proxy->log_cmb_registration("Valid IPN Request");
                $this->Walk_proxy->log_cmb_registration("TXN ID: ".$this->paypal_lib->ipn_data['txn_id']);
			
				$curyear = $this->Walk_proxy->getCurrentYear();

				$bq_registration_value = unserialize($this->Paypal_proxy->getTempData( $this->paypal_lib->ipn_data['custom'] ));
				$bq_registration_value = Annualbanquet_registration_value::cast( $bq_registration_value );

				$eventID = $bq_registration_value->getEventID();
				$desc = $this->Annualbanquet_proxy->getEventName( $eventID );
								
				//Insert into 'bq_reg_history'
				$tmp = $this->Annualbanquet_proxy->insertBQRegistrationPayPal($bq_registration_value, $curyear, $this->paypal_lib->ipn_data['txn_id']);
				
				//Send email confirming payment and registration
				$this->Annualbanquet_proxy->sendEventRegistrationConfirmEmailPaypal( $bq_registration_value, $desc, $curyear, $this->paypal_lib->ipn_data['txn_id']);
				
				//Remove value object from temp table
				$this->Paypal_proxy->removeTempData( $this->paypal_lib->ipn_data['custom'] );
				
				$this->session->unset_userdata('sessionobj_temp_id');
				$this->session->unset_userdata('bq_registration_value');
			}
		}
		
		public function pay_by_check( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/Paypal_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
			
			$currentyear = $this->Walk_proxy->getCurrentYear();
			
			$paypalTempId = $this->session->userdata('sessionobj_temp_id');
			if ($paypalTempId <= 0)
			{
				redirect( base_url() . 'annualbanquet/banquet_registration/registration_error/'.$eventID);
			}
			$bq_registration_value = unserialize($this->session->userdata('bq_registration_value'));				
			$bq_registration_value = Annualbanquet_registration_value::cast($bq_registration_value);
			
			$total_fee = $bq_registration_value->getTotalRegistrationFee();
			
			$desc = $this->Annualbanquet_proxy->getEventName( $eventID );
			
			//Insert into 'sv_reg_history'
			$tmp = $this->Annualbanquet_proxy->insertBQRegistrationCheck($bq_registration_value, $currentyear);

			//Send email to member with instructions on sending the check
			$this->Annualbanquet_proxy->sendEventRegistrationByCheckEmail( $bq_registration_value, $desc, $currentyear );
			
			//Remove temporary entry for Paypal
			$this->Walk_proxy->deleteRegTempObj( $paypalTempId );
			$this->session->unset_userdata('bq_registration_value');
			
			switch ($eventID)
			{
				case 1:
					$data['title'] = $currentyear.' '.$desc.' Registration - Payment By Check';
					$data['view'] = 'annualbanquet/bq_paybycheck_view';
					$data['curyear'] = $currentyear;
					$data['total_fee'] = $total_fee;
					$data['desc'] = $desc;
		
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}			
		}

		//Admin release checks associated with various events
		public function release_check_event( $urlKey )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->model('proxies/Person_proxy');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' );
			}
			
			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );			
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$personId = $this->Person_proxy->getPrimaryPersonID( $urlKey );
			if ( $personId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			$group = $this->Person_proxy->getPersonGroup( $personId );
			$role = $this->Person_proxy->getPersonRole( $personId );
			
			if (in_array('admin',$role) or in_array('superadmin',$role))
			{
				$curyear = $this->Walk_proxy->getCurrentYear();
				$regInfo = $this->Annualbanquet_proxy->getEventUnpaidCheckInfo( $curyear );
				
				if (count($regInfo) > 0)
				{
					$data['title'] = 'Release Checks Received for Various Events';
					$data['curyear'] = $curyear;
					$data['view'] = 'annualbanquet/bq_release_check_view';
					$data['regInfo'] = $regInfo;
					$data['urlKey'] = $urlKey;
					
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				}
				else
				{
					echo('<b>No Unreleased Transactions</b>');
					die;
				}
			}
			else
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );			
			}
		}

		public function release_check_event_process( $urlKey )
		{
			$this->load->model('proxies/Person_proxy');
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('values/annualbanquet/Annualbanquet_registration_value');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			$this->load->library('encrypt');
			
			$is_logged_in = $this->session->userdata( 'is_logged_in' );
			if (!$is_logged_in)
			{
				redirect( base_url() . 'cmb/member/login_home/' . $urlKey . '/' );
			}

			$seckey = $this->Person_proxy->getPersonSecurityKey( $this->session->userdata( 'person_id' ) );		
			if ($seckey != $this->session->userdata( 'logged_in_key' ))
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}

			$personId = $this->Person_proxy->getPrimaryPersonID( $urlKey );
			if ( $personId < 1 )
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );
			}
			
			$group = $this->Person_proxy->getPersonGroup( $personId );
			$role = $this->Person_proxy->getPersonRole( $personId );

			$curyear = $this->Walk_proxy->getCurrentYear();

			if (in_array('admin',$role) or in_array('superadmin',$role))
			{
				//Get check info
				$RegIdArray = $this->Annualbanquet_proxy->getEventUnpaidCheckRegId( $curyear );
				
				for( $i = 0; $i < count($RegIdArray); $i++ )
				{
					$checknum = $this->input->post('bqid'.$RegIdArray[$i]);
					if ($checknum != "")
					{				
						//Update 'bq_reg_history' for check payment
						$tmp = $this->Annualbanquet_proxy->completeBQRegistrationCheck($RegIdArray[$i], $checknum);
	
						//Get registration value object
						$bq_registration_value = $this->Annualbanquet_proxy->getEventInfoYear($RegIdArray[$i], $curyear);
													
						$this->Annualbanquet_proxy->sendEventRegistrationCheckConfirmEmail( $bq_registration_value, $curyear);
					}
				}
							
				redirect( base_url() . 'cmb/member/home/' . $urlKey . '/' );
			}
			else
			{
				redirect( base_url() . 'cmb/member/login_home/true/' );			
			}
		}

		public function paypal_success( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			
			$curyear = $this->Walk_proxy->getCurrentYear();
			$desc = $this->Annualbanquet_proxy->getEventName( $eventID );
			
			switch ($eventID)
			{
				case 1:
					$data['title'] = 'Registration Confirmed for '.$curyear.' '.$desc;
					$data['view'] = 'annualbanquet/bq_registration_success_view';
					$data['curyear'] = $this->Walk_proxy->getCurrentYear();
					$data['desc'] = $desc;
							
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}			
		}

		public function registration_error( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			
			$curyear = $this->Walk_proxy->getCurrentYear();
			$desc = $this->Annualbanquet_proxy->getEventName( $eventID );

			switch ($eventID)
			{
				case 1:
					$data['title'] = 'An error occurred during registration for '.$curyear.' '.$desc;
					$data['view'] = 'annualbanquet/registration_bq_error_view';
					$data['curyear'] = $curyear;
					$data['desc'] = $desc;
					
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}			
		}

		public function event_registered( $eventID )
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');
			
			$curyear = $this->Walk_proxy->getCurrentYear();
			$desc = $this->Annualbanquet_proxy->getEventName( $eventID );
			
			//echo $desc."</br>";
			
			switch ($eventID)
			{
				case 1:
					$data['title'] = 'Already Registered for '.$curyear.' '.$desc;
					$data['view'] = 'annualbanquet/bq_registered_view';
					$data['curyear'] = $curyear;
					$data['desc'] = $desc;
					
					$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
				break;
			}			
		}

		public function paypal_cancel()
		{
			redirect( base_url() );
			die;
		}

		public function bq_directions()
		{
			$this->load->model('proxies/Walk_proxy');
			$this->load->model('proxies/annualbanquet/Annualbanquet_proxy');

			$curyear = $this->Walk_proxy->getCurrentYear();
			$eventID = 1;
			$desc = $this->Annualbanquet_proxy->getEventName( $eventID );
			
			$data['title'] = 'Directions for '.$curyear.' '.$desc;
			$data['view'] = 'annualbanquet/bq_directions_view';
			$data['curyear'] = $curyear;
			$data['desc'] = $desc;
					
			$this->load->view( self::$REGISTRATION_TEMPLATE, $data );
		}
	}
?>